
import requests
from scrapy_plus.https.response import Response
class Downloader(object):
    def get_response(self, request):

        if request.method == "GET":

            response = requests.get(request.url, headers=request.headers, params=request.params )

        elif request.method == "POST":
            response = requests.post(request.url, headers=request.headers, data=request.data)

        else:
            raise Exception('不支持{}方式，　只支持get和post'.format(request.method))

        return Response(
            url=response.url,
            headers=response.headers,
            request=request,
            body=response.content,
            code=response.status_code,
            meta={},
        )








